$(function(){
$.ajaxSetup({
	 beforeSend: function(request) {
       request.setRequestHeader("X-AIRPORT-TOKEN", localStorage.getItem("oauth_token"));
   }
})
var searchURL=window.location.search;
if(searchURL.indexOf("showList")!=-1){
	var ssid=searchURL.substring(10,searchURL.indexOf("&"))
	var senderId=searchURL.substring(searchURL.indexOf("&")+10,searchURL.indexOf("&ouath_token"))
	$("#specialMainIframe").attr('src',baseURL+"/api/special/page/receive?ssid="+ssid+"&senderId="+senderId+"&ouath_token="+localStorage.getItem("oauth_token"))	
}else $("#specialMainIframe").attr('src',baseURL+"/api/special/page?ouath_token="+localStorage.getItem("oauth_token"))	
$("#specialMainIframe").attr('height',document.documentElement.clientHeight-65)		
$(window).resize(function(){
	$("#specialMainIframe").attr('height',document.documentElement.clientHeight-65)	
})	
$('.Hui-header').find('h3').on('click',function(e){
	e.stopPropagation();
	$(e.target).addClass('specialMainNav')
	$(e.target).siblings().removeClass("specialMainNav")
	switch($(e.target).attr('data-url')){
		case "0" :
			$("#specialMainIframe").attr('src',baseURL+"/api/special/page?ouath_token="+localStorage.getItem("oauth_token"))		
		break;
		case "1" :
			$("#specialMainIframe").attr('src',baseURL+"/api/special/page/history?ouath_token="+localStorage.getItem("oauth_token"))
		break;
		case "2" :
			$("#specialMainIframe").attr('src',baseURL+"/api/special/pageTemplet/list?ouath_token="+localStorage.getItem("oauth_token"))	
		break;
		default:$("#specialMainIframe").attr('src',baseURL+"/api/special/page?ouath_token="+localStorage.getItem("oauth_token"))
	}
})

var loadResource=function(){
	$.ajax({  
	    type: "get",     
	    url: baseURL+'/api/special/getResources',     
	    dataType: "json",   
	    contentType: "application/json",
	    success: function(result) {
	    	if(!result.flag){
	    		  layer.msg("数据错误原因："+result.message);
	    		  return;
	    	  }
	    	  if(result.flag){
		    	  var objData=result.results;
		    	  $.each(objData,function(index,resource){
		    		  if(resource.code=='special_publish'){
		    			  $('.Hui-header h3:eq(2)').css('display','block');
		    		  }
		    	  });
	    	  }
	    }
   });
}
loadResource();



var  reloadFlag = window.localStorage.getItem("reloadFlag");
if(reloadFlag=="false"){
   setTimeout(function(){
	   window.location.reload();
   },100); 
   window.localStorage.setItem("reloadFlag","true");
}	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
})